﻿using System;

namespace diantou.web
{
    /// <summary>
    /// 用户动态关系
    /// </summary>
    struct userItem
    {
        /// <summary>
        /// 用户动态
        /// </summary>
        public diantou.dataAccess.item Item;
        /// <summary>
        /// 用户信息
        /// </summary>
        public diantou.dataAccess.user User;
        /// <summary>
        /// 用户标识
        /// </summary>
        public int UserId
        {
            get { return User == null ? 0 : User.Id; }
        }
        /// <summary>
        /// 用户问题关系
        /// </summary>
        public web.question.userQuestion UserQuestion
        {
            get { return new web.question.userQuestion { Question = Item.Question, UserId = UserId }; }
        }
        /// <summary>
        /// 用户回答关系
        /// </summary>
        public web.answer.userAnswer UserAnswer
        {
            get { return new web.answer.userAnswer { Answer = Item.Answer, UserId = UserId }; }
        }
        /// <summary>
        /// 用户OJ问题关系
        /// </summary>
        public web.onlineJudge.userProblem UserProblem
        {
            get { return new web.onlineJudge.userProblem { Problem = Item.Problem, User = User }; }
        }
        /// <summary>
        /// 用户比赛关系
        /// </summary>
        public contest.userContest UserContest
        {
            get { return new contest.userContest { Contest = Item.Contest, User = User }; }
        }
        /// <summary>
        /// 用户问题评论
        /// </summary>
        public userComment<diantou.dataAccess.questionComment, diantou.dataAccess.question, diantou.dataAccess.question.memberCache> UserQuestionComment
        {
            get { return new userComment<diantou.dataAccess.questionComment, diantou.dataAccess.question, diantou.dataAccess.question.memberCache> { Comment = Item.QuestionComment, UserId = UserId }; }
        }
        /// <summary>
        /// 用户回答评论
        /// </summary>
        public userComment<diantou.dataAccess.answerComment, diantou.dataAccess.answer, diantou.dataAccess.answer> UserAnswerComment
        {
            get { return new userComment<diantou.dataAccess.answerComment, diantou.dataAccess.answer, diantou.dataAccess.answer> { Comment = Item.AnswerComment, UserId = UserId }; }
        }
    }
}
